home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / commontex / c / hyph < prev    next >
Encoding:
Text File  |  1988-04-18  |  25.7 KB  |  770 lines

  1. /*
  2.  *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
  3.  *    Copying of this file is granted according to the provisions 
  4.  *    specified in the file COPYING which must accompany this file.
  5.  */
  6.  
  7.  
  8. /*
  9.  *              hyph.c
  10.  */
  11.  
  12. #include        "tex.h"
  13. #include        "cmds.h"
  14. #include        "heap.h"
  15. #include        "token.h"
  16. #include        "eq.h"
  17. #include        "str.h"
  18. #include        "tfm.h"
  19. #include        "box.h"
  20. #include        "scan.h"
  21. #include        "tokenstack.h"
  22. #include        "par.h"
  23. #include        "print.h"
  24. #include        "error.h"
  25. #include        "hyph.h"
  26.  
  27. ptr             ha;
  28. ptr             hb;
  29. hword   hc[66];
  30. fnt             hf;
  31. int             hn;
  32. ascii   hu[64];
  33. byte    hyf[65];
  34. int             hyf_char;
  35. int             hyf_distance[256];
  36. qword   hyf_next[256];
  37. int             hyf_num[256];
  38. int             hyph_count;
  39. ptr             hyph_list[HYPH_SIZE+1];
  40. str             hyph_word[HYPH_SIZE+1];
  41. int             hyphen_passed;
  42. int             trie_max;
  43. qword   trie_op_ptr;
  44. twoh    trie[TRIE_SIZE+1];
  45.  
  46. hyphenate ()
  47. {
  48.         ascii   c;
  49.         int             h;
  50.         int             i;
  51.         int             j;
  52.         str             k;
  53.         int             l;
  54.         ptr             q;
  55.         ptr             r;
  56.         ptr             s;
  57.         int             u;
  58.         qword   v;
  59.         int             z;
  60.         ptr             hyf_node;
  61.         ptr             major_tail;
  62.         ptr             minor_tail;
  63.  
  64.         for (j = 0; j <= hn; incr(j))
  65.                 hyf[j] = 0;
  66.         h = hc[1];
  67.         for (j = 2; j <= hn; incr(j))
  68.                 h = (h + h + hc[j]) % HYPH_SIZE;
  69.         loop {
  70.                 k = hyph_word[h];
  71.                 if (k == 0) goto not_found;
  72.                 if (length(k) < hn)     goto not_found;
  73.                 if (length(k) == hn) {
  74.                         j = 1;
  75.                         u = str_start[k];
  76.                         do {
  77.                                 if (str_pool[u] < hc[j]) goto not_found;
  78.                                 if (str_pool[u] > hc[j]) goto done;
  79.                                 incr(u); incr(j);
  80.                         } while (j <= hn);
  81.                         for (s = hyph_list[h]; s != NULL; s = link(s))
  82.                                 hyf[info(s)] = 1;
  83.                         goto found;
  84.                 }
  85.  
  86.         done:
  87.                 if (h > 0)
  88.                         decr(h);
  89.                 else h = HYPH_SIZE;
  90.         }
  91.  
  92. not_found:
  93.         hc[0] = 127;
  94.         hc[hn + 1] = 127;
  95.         hc[hn + 2] = 256;
  96.         for (j = 0; j <= hn - 2; incr(j)) {
  97.                 z = hc[j];
  98.                 l = j;
  99.                 while (hc[l] == trie_char(z)) {
  100.                         if (trie_op(z) != MIN_QUARTERWORD) {
  101.                                 v = trie_op(z);
  102.                                 do {
  103.                                         i = l - hyf_distance[v];
  104.                                         if (hyf_num[v] > hyf[i])
  105.                                                 hyf[i] = hyf_num[v];
  106.                                         v = hyf_next[v];
  107.                                 } while (v != MIN_QUARTERWORD);
  108.                         }
  109.                         incr(l);
  110.                         z = trie_link(z) + hc[l];
  111.                 }
  112.         }
  113.  
  114. found:
  115.         hyf[1] = 0;
  116.         hyf[hn - 2] = 0;
  117.         hyf[hn - 1] = 0;
  118.         hyf[hn] = 0;
  119.  
  120.         for (j = 2; j <= hn - 3; incr(j))
  121.                 if (odd(hyf[j])) goto found1;
  122.         return;
  123.  
  124. found1:
  125.         q = link(hb);
  126.         link(hb) = NULL;
  127.         s = cur_p;
  128.         while (link(s) != ha)
  129.                 s = link(s);
  130.         link(s) = NULL;
  131.         flush_node_list(ha);
  132.         j = 0;
  133.         do {
  134.                 l = j;
  135.                 j = reconstitute(j + 1, hn);
  136.                 if (hyphen_passed != 0) {
  137.                         r = get_node(SMALL_NODE_SIZE);
  138.                         link(s) = r;
  139.                         link(r) = link(hold_head);
  140.                         type(r) = DISC_NODE;
  141.                         major_tail = link(hold_head);
  142.                         if (link(major_tail) != NULL)
  143.                                 major_tail = link(major_tail);
  144.                         i = hyphen_passed;
  145.                         minor_tail = NULL;
  146.                         hyf_node = new_character(hf, (ascii) hyf_char);
  147.                         if (hyf_node != NULL) {
  148.                                 incr(i);
  149.                                 c = hu[i];
  150.                                 hu[i] = hyf_char;
  151.                         }
  152.                         do {
  153.                                 l = reconstitute(l + 1, i);
  154.                                 if (minor_tail == NULL)
  155.                                         pre_break(r) = link(hold_head);
  156.                                 else link(minor_tail) = link(hold_head);
  157.                                 minor_tail = link(hold_head);
  158.                                 if (link(minor_tail) != NULL)
  159.                                         minor_tail = link(minor_tail);
  160.                         } while (l != i);
  161.                         if (hyf_node != NULL) {
  162.                                 hu[i] = c;
  163.                                 free_avail(hyf_node);
  164.                                 decr(i);
  165.                                 l = i;
  166.                         }
  167.                         hyf[i] = 0;
  168.                         minor_tail = NULL;
  169.                         post_break(r) = NULL;
  170.                         while (l < j) {
  171.                                 do {
  172.                                         l = reconstitute(l + 1, hn);
  173.                                         if (minor_tail == NULL)
  174.                                                 post_break(r) = link(hold_head);
  175.                                         else link(minor_tail) = link(hold_head);
  176.                                         minor_tail = link(hold_head);
  177.                                         if (link(minor_tail) != NULL) {
  178.                                                 hyf[l] = 0;
  179.                                                 minor_tail = link(minor_tail);
  180.                                         }
  181.                                 } while (l < j);
  182.                                 while (l > j) {
  183.                                         j = reconstitute(j + 1, hn);
  184.                                         link(major_tail) = link(hold_head);
  185.                                         major_tail = link(hold_head);
  186.                                         if (link(major_tail) != NULL) {
  187.                                                 hyf[j] = 0;
  188.                                                 major_tail = link(major_tail);
  189.                                         }
  190.                                 }
  191.                         }
  192.                         i = 0; 
  193.                         s = r;
  194.                         while(link(s) != NULL) {
  195.                                 incr(i);
  196.                                 s =  link(s);
  197.                         }
  198.                         replace_count(r) = i;
  199.                 } else {
  200.                         link(s) = link(hold_head);
  201.                         s = link(s);
  202.                         if (link(s) != NULL)
  203.                                 s = link(s);
  204.                 }
  205.                 if (odd(hyf[j])) {
  206.                         r = new_disc();
  207.                         pre_break(r) = new_character(hf, (ascii) hyf_char);
  208.                         link(s) = r;
  209.                         s = r;
  210.                 }
  211.         } while (j != hn);
  212.         link(s) = q;
  213. }
  214.         
  215. reconstitute (j, n)
  216.         int             j;
  217.         int             n;
  218. {
  219.         qword   c;
  220.         qword   d;
  221.         ptr             p;
  222.         fourq   q;
  223.         int             r;
  224.         ptr             s;
  225.         scal    w;
  226.  
  227.         hyphen_passed = 0;
  228.         s = hold_head;
  229.         w = 0;
  230.         c = d = qi(hu[j]);
  231.         loop {
  232. contin: p = get_avail();
  233.                 font(p) = hf;
  234.                 character(p) = c;
  235.                 link(s) = p;
  236.                 if (j == n) break;
  237.                 q = char_info(hf, d);
  238.                 if (char_tag(q) != LIG_TAG) break;
  239.                 r = lig_kern_start(hf, q);
  240.                 c = qi(hu[j + 1]);
  241.                 loop {
  242.                         q = font_info[r].qqqq;
  243.                         if (next_char(q) == c) {
  244.                                 if (odd(hyf[j]) && hyphen_passed == 0)
  245.                                         hyphen_passed = j;
  246.                                 if (op_bit(q) < KERN_FLAG) {
  247.                                         d = rem_byte(q);
  248.                                         incr(j);
  249.                                         s = p;
  250.                                         goto contin;
  251.                                 } else {
  252.                                         w = char_kern(hf, q);
  253.                                         goto done;
  254.                                 }
  255.                         } else if (stop_bit(q) < STOP_FLAG)
  256.                                 incr(r);
  257.                         else goto done;
  258.                 }
  259.         }
  260.  
  261. done:
  262.         if (s != hold_head) {
  263.                 p = new_ligature(hf, d, link(hold_head));
  264.                 link(hold_head) = p;
  265.         }
  266.         if (w != 0)
  267.                 link(link(hold_head)) = new_kern(w);
  268.         return j;
  269. }
  270.  
  271. new_hyph_exceptions ()
  272. {
  273.         int             h;
  274.         int             j;
  275.         str             k;
  276.         int             n;
  277.         ptr             p;
  278.         ptr             q;
  279.         str             s;
  280.         str             t;
  281.         int             u;
  282.         int             v;
  283.  
  284.         n = 0;
  285.         p = NULL;
  286.         scan_left_brace();
  287.         loop {
  288.                 get_x_token();
  289.  
  290.         reswitch:
  291.                 switch (cur_cmd)
  292.                 {
  293.                 case LETTER:
  294.                 case OTHER_CHAR:
  295.                 case CHAR_GIVEN:
  296.                         if (cur_chr == '-') {
  297.                                 if (n > 1) {
  298.                                         q = get_avail();
  299.                                         link(q) = p;
  300.                                         info(q) = n;
  301.                                         p = q;
  302.                                 }
  303.                         } else {
  304.                                 if (cur_chr > 127 || lc_code(cur_chr) == 0) {
  305.                                         print_err("Not a letter");
  306.                                         help_hyph_lccode();
  307.                                         error();
  308.                                 } else if (n < 63) {
  309.                                         incr(n);
  310.                                         hc[n] = lc_code(cur_chr) - 1;
  311.                                 }
  312.                         }
  313.                         break;
  314.                 
  315.                 case CHAR_NUM:
  316.                         scan_char_num();
  317.                         cur_chr = cur_val;
  318.                         cur_cmd = CHAR_GIVEN;
  319.                         goto reswitch;
  320.                         break;
  321.  
  322.                 case SPACER:
  323.                 case RIGHT_BRACE:
  324.                         if (n > 4) {
  325.                                 str_room(n);
  326.                                 h = 0;
  327.                                 for (j = 1; j <= n; incr(j)) {
  328.                                         h = (h + h + hc[j]) % HYPH_SIZE;
  329.                                         append_char(hc[j]);
  330.                                 }
  331.                                 s = make_string();
  332.                                 loop {
  333.                                         if (p == NULL)
  334.                                                 break;
  335.                                         if (info(p) < n - 2)
  336.                                                 break;
  337.                                         q = link(p);
  338.                                         free_avail(p);
  339.                                         p = q;
  340.                                 }
  341.                                 if (hyph_count == HYPH_SIZE)
  342.                                         overflow("exception dictionary", HYPH_SIZE);
  343.                                 incr(hyph_count);
  344.                                 while (hyph_word[h] != 0) {
  345.                                         k = hyph_word[h];
  346.                                         if (length(k) < length(s))
  347.                                                 goto found;
  348.                                         if (length(k) > length(s))
  349.                                                 goto not_found;
  350.                                         u = str_start[k];
  351.                                         v = str_start[s];
  352.                                         do {
  353.                                                 if (str_pool[u] < str_pool[v])
  354.                                                         goto found;
  355.                                                 if (str_pool[u] > str_pool[v])
  356.                                                         goto not_found;
  357.                                                 incr(u); incr(v);
  358.                                         } while (u != str_start[k + 1]);
  359.  
  360.                                 found:
  361.                                         q = hyph_list[h];
  362.                                         hyph_list[h] = p;
  363.                                         p = q;
  364.                                         t = hyph_word[h];
  365.                                         hyph_word[h] = s;
  366.                                         s = t;
  367.                                 
  368.                         not_found:
  369.                                         if (h > 0)
  370.                                                 decr(h);
  371.                                         else h = HYPH_SIZE;
  372.                                 }
  373.                                 hyph_word[h] = s;
  374.                                 hyph_list[h] = p;
  375.                         }
  376.                         if (cur_cmd == RIGHT_BRACE)
  377.                                 return;
  378.                         n = 0;
  379.                         p = NULL;
  380.                         break;
  381.  
  382.                 default:
  383.                         print_err("Improper ");
  384.                         print_esc("hyphenation");
  385.                         print(" will be flushed");
  386.                         help_hyph();
  387.                         error();
  388.                         break;
  389.                 }
  390.         }
  391. }
  392.  
  393. /*
  394.  *      Help text
  395.  */
  396.  
  397. help_hyph_lccode ()
  398. {
  399.         help2("Letters in \\hyphenation words must have \\lccode > 0",
  400.         "Proceed; I'll ignore the character I just read.");
  401. }
  402.  
  403. help_hyph ()
  404. {
  405.         help2("Hyphenation exceptions must contain only letters",
  406.         "and hyphens. But continue; I'll forgive and forget.");
  407. }
  408.  
  409. #ifdef INIT
  410.  
  411. qword   trie_op_hash[TRIE_OP_HASH_SIZE+1];      
  412. /* qword        trie_op_ptr; ***BUG*** - already declared. (GT 08/04/88) */
  413.  
  414. int             trie_hash[TRIE_SIZE+1];
  415. ascii   trie_c[TRIE_SIZE+1];
  416. qword   trie_o[TRIE_SIZE+1];
  417. int             trie_l[TRIE_SIZE+1];
  418. int             trie_r[TRIE_SIZE+1];
  419. int             trie_min;
  420. int             trie_ptr;
  421. bool    trie_taken[TRIE_SIZE+1];
  422.  
  423. qword
  424. new_trie_op (d, n, v)
  425.         int             d;
  426.         int             n;
  427.         qword   v;
  428. {
  429.         int             h;
  430.         qword   u;
  431.  
  432.         h = abs(n + 313 * d + 361 * v) % TRIE_OP_HASH_SIZE;
  433.         loop {
  434.                 u = trie_op_hash[h];
  435.                 if (u == MIN_QUARTERWORD) {
  436.                         if (trie_op_ptr == MAX_QUARTERWORD)
  437.                                 return MIN_QUARTERWORD;
  438.                         incr(trie_op_ptr);
  439.                         hyf_distance[trie_op_ptr] = d;
  440.                         hyf_num[trie_op_ptr] = n;
  441.                         hyf_next[trie_op_ptr] = v;
  442.                         trie_op_hash[h] = trie_op_ptr;
  443.                         return trie_op_ptr;
  444.                 }
  445.                 if (hyf_distance[u] == d && 
  446.                         hyf_num[u] == n &&
  447.                         hyf_next[u] == v)
  448.                                 return u;
  449.                 if (h > 0)
  450.                         decr(h);
  451.                 else h = TRIE_OP_HASH_SIZE;
  452.         }
  453. }
  454.                 
  455. trie_node (p)
  456.         int             p;
  457. {
  458.         int             h;
  459.         int             q;
  460.  
  461.         h = abs(trie_c[p] + 
  462.                         1009 * trie_o[p] +
  463.                         2718 * trie_l[p] +
  464.                         3142 * trie_r[p])
  465.                         % TRIE_SIZE;
  466.         loop {
  467.                 q = trie_hash[h];
  468.                 if (q == 0) {
  469.                         trie_hash[h] = p; 
  470.                         return p;
  471.                 }
  472.                 if (trie_c[q] == trie_c[p] &&
  473.                         trie_o[q] == trie_o[p] &&
  474.                         trie_l[q] == trie_l[p] && 
  475.                         trie_r[q] == trie_r[p])
  476.                         return q;
  477.                 if (h > 0) 
  478.                         decr(h);
  479.                 else h = TRIE_SIZE;
  480.         }
  481. }
  482.  
  483. compress_trie (p)
  484.         int             p;
  485. {
  486.         if (p == 0)
  487.                 return 0;
  488.         else {
  489.                 trie_l[p] = compress_trie(trie_l[p]);
  490.                 trie_r[p] = compress_trie(trie_r[p]);
  491.                 return (trie_node(p));
  492.         }
  493. }
  494.  
  495. init_pattern_memory ()
  496. {
  497.         int             h;
  498.         int             p;
  499.  
  500.         for (h = 0; h <= TRIE_OP_HASH_SIZE; incr(h))
  501.                 trie_op_hash[h] = MIN_QUARTERWORD;
  502.         trie_op_ptr = MIN_QUARTERWORD;
  503.         trie_root = 0;
  504.         trie_c[0] = 0;
  505.         trie_ptr = 0;
  506.         for (p = 0; p <= TRIE_SIZE; incr(p))
  507.                 trie_hash[p] = 0;
  508. }
  509.  
  510. init_trie_memory ()
  511. {
  512.         int             p;
  513.  
  514.         for (p = 0; p <= trie_ptr; incr(p))
  515.                 trie_ref[p] = 0;
  516.         trie_max = trie_min = 128;
  517.         trie_link(0) = 1;
  518.         trie_taken[0] = FALSE;
  519.         for (p = 1; p <= 128; p++) {
  520.                 trie_back(p) = p - 1;
  521.                 trie_link(p) = p + 1;
  522.                 trie_taken[p] = FALSE;
  523.         }
  524. }
  525.  
  526. first_fit (p)
  527.         int             p;
  528. {
  529.         ascii   c;
  530.         int             h;
  531.         int             q;
  532.         int             z;
  533.  
  534.         c = trie_c[p];
  535.         if (c < trie_min)
  536.                 trie_min = c;
  537.         z = trie_link(trie_min - 1);
  538.         loop {
  539.                 if (z < c)
  540.                         goto not_found;
  541.                 h = z - c;
  542.                 if (trie_max < h + 128) {
  543.                         if (TRIE_SIZE <= h + 128)
  544.                                 overflow("pattern memory", TRIE_SIZE);
  545.                         do {
  546.                                 incr(trie_max); 
  547.                                 trie_taken[trie_max] = FALSE;
  548.                                 trie_link(trie_max) = trie_max + 1;
  549.                                 trie_back(trie_max) = trie_max - 1;
  550.                         } while (trie_max != h + 128);
  551.                 }
  552.                 if (trie_taken[h])
  553.                         goto not_found;
  554.                 for (q = trie_r[p]; q > 0; q = trie_r[q])
  555.                         if (trie_link(h + trie_c[q]) == 0)
  556.                                 goto not_found;
  557.                 goto found;
  558.  
  559.         not_found:
  560.                 z = trie_link(z);
  561.         }
  562.  
  563. found:
  564.         trie_taken[h] = TRUE;
  565.         trie_ref[p] = h;
  566.         q = p;
  567.         do {
  568.                 z = h + trie_c[q];
  569.                 trie_back(trie_link(z)) = trie_back(z);
  570.                 trie_link(trie_back(z)) = trie_link(z);
  571.                 trie_link(z) = 0;
  572.                 q = trie_r[q];
  573.         } while (q != 0);
  574. }
  575.  
  576. trie_pack (p)
  577.         int             p;
  578. {
  579.         int             q;
  580.  
  581.         do {    
  582.                 q = trie_l[p];
  583.                 if (q > 0 && trie_ref[q] == 0) {
  584.                         first_fit(q);
  585.                         trie_pack(q);
  586.                 }
  587.                 p = trie_r[p];
  588.         } while (p != 0);
  589. }
  590.  
  591. trie_fix (p)
  592.         int             p;
  593. {
  594.         ascii   c;
  595.         int             q;
  596.         int             z;
  597.  
  598.         z = trie_ref[p];
  599.         while (p != 0) {
  600.                 q = trie_l[p];
  601.                 c = trie_c[p];
  602.                 trie_link(z + c) = trie_ref[q];
  603.                 trie_char(z + c) = c;
  604.                 trie_op(z + c) = trie_o[p];
  605.                 if (q > 0)
  606.                         trie_fix(q);
  607.                 p = trie_r[p];
  608.         }
  609. }
  610.  
  611. new_patterns ()
  612. {
  613.         ascii   c;
  614.         twoh    h;
  615.         int             k;
  616.         int             l;
  617.         int             p;
  618.         int             q;
  619.         int             r;
  620.         int             s;
  621.         qword   v;
  622.         bool    digit_sensed;
  623.         bool    first_child;
  624.  
  625.         scan_left_brace();
  626.         init_pattern_memory();
  627.         k = 0;
  628.         hyf[0] = 0;
  629.         digit_sensed = FALSE;
  630.         loop {
  631.                 get_x_token();
  632.                 switch (cur_cmd)
  633.                 {
  634.                 case LETTER:
  635.                 case OTHER_CHAR:
  636.                         if (digit_sensed || cur_chr < '0' || cur_chr > '9') {
  637.                                 if (cur_chr == '.')
  638.                                         cur_chr = 128;
  639.                                 else {
  640.                                         cur_chr = lc_code(cur_chr);
  641.                                         if (cur_chr == 0) {
  642.                                                 print_err("Nonletter");
  643.                                                 help1("(See Appendix H.)");
  644.                                                 error();
  645.                                                 cur_chr = 128;
  646.                                         }
  647.                                 }
  648.                                 if (k < 63) {
  649.                                         incr(k);
  650.                                         hc[k] = cur_chr - 1;
  651.                                         hyf[k] = 0;
  652.                                         digit_sensed = FALSE;
  653.                                 }
  654.                         } else {
  655.                                 hyf[k] = cur_chr - '0';
  656.                                 if (k < 63)
  657.                                         digit_sensed = TRUE;
  658.                         }
  659.                         break;
  660.  
  661.                 case SPACER:
  662.                 case RIGHT_BRACE:
  663.                         if (k > 0) {
  664.                                 if (hc[1] == 127)
  665.                                         hyf[0] = 0;
  666.                                 if (hc[k] == 127)
  667.                                         hyf[k] = 0;
  668.                                 l = k;
  669.                                 v = MIN_QUARTERWORD;
  670.                                 loop {
  671.                                         if (hyf[l] != 0)
  672.                                                 v = new_trie_op(k - l, hyf[l], v);
  673.                                         if (l > 0)
  674.                                                 decr(l);
  675.                                         else break;
  676.                                 }
  677.                                 q = 0; 
  678.                                 while (l < k) {
  679.                                         incr(l);
  680.                                         c = hc[l];
  681.                                         p = trie_l[q];
  682.                                         first_child = TRUE;
  683.                                         while (p > 0 && c > trie_c[p]) {
  684.                                                 q = p;
  685.                                                 p = trie_r[q];
  686.                                                 first_child = FALSE;
  687.                                         }
  688.                                         if (p == 0 || c < trie_c[p]) {
  689.                                                 if (trie_ptr == TRIE_SIZE)
  690.                                                         overflow("pattern memory", TRIE_SIZE);
  691.                                                 incr(trie_ptr);
  692.                                                 trie_r[trie_ptr] = p;
  693.                                                 p = trie_ptr;
  694.                                                 trie_l[p] = 0;
  695.                                                 if (first_child)
  696.                                                         trie_l[q] = p;
  697.                                                 else trie_r[q] = p;
  698.                                                 trie_c[p] = c;
  699.                                                 trie_o[p] = MIN_QUARTERWORD;
  700.                                         }
  701.                                         q = p;
  702.                                 }
  703.                                 if (trie_o[q] != MIN_QUARTERWORD) {
  704.                                         print_err("Duplicate pattern");
  705.                                         help1("(See Appendix H.)");
  706.                                         error();
  707.                                 }
  708.                                 trie_o[q] = v;
  709.                         }
  710.                         if (cur_cmd == RIGHT_BRACE)
  711.                                 goto done;
  712.                         k = 0;
  713.                         hyf[0] = 0;
  714.                         digit_sensed = FALSE;
  715.                         break;
  716.  
  717.                 default:
  718.                         print_err("Bad ");
  719.                         print_esc("patterns");
  720.                         help1("(See Appendix H.)");
  721.                         error();
  722.                         break;
  723.                 }
  724.         }
  725.  
  726. done:
  727.         trie_root = compress_trie(trie_root);
  728.         init_trie_memory();
  729.         if (trie_root != 0) {
  730.                 first_fit(trie_root);
  731.                 trie_pack(trie_root);
  732.         }
  733.         r = 0;
  734.         while (trie_taken[r])
  735.                 incr(r);
  736.         trie_ref[0] = r;
  737.         trie_fix(trie_root);
  738.         r = 0;
  739.         h.hh2.rh = 0;
  740.         h.hh2.b0 = 0;
  741.         h.hh2.b1 = 0;
  742.         do {
  743.                 s = trie_link(r);
  744.                 trie[r] = h;
  745.                 r = s;
  746.         } while (r <= trie_max);
  747. }
  748. #endif
  749.  
  750. init_hyph ()
  751. {
  752. #ifdef INIT
  753.         int             k;
  754.         int             z;
  755.  
  756.         trie_op_ptr = MIN_QUARTERWORD;
  757.         trie_link(0) = 0;
  758.         trie_char(0) = 0;
  759.         trie_op(0) = 0;
  760.         for (k = 1; k <= 127; k++)
  761.                 trie[k] = trie[0];
  762.         trie_max = 127;
  763.         for (z = 0; z <= HYPH_SIZE; z++) {
  764.                 hyph_word[z] = 0;
  765.                 hyph_list[z] = NULL;
  766.         }
  767.         hyph_count = 0;
  768. #endif
  769. }
  770.